<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <search ref='search' :config='searchConfig' @search='search' @getHeight='getHeight' />

    <div class='page_table'>
      <vxe-grid
        ref='xGrid'
        :border='true'
        :resizable='true'
        :showOverflow='true'
        size='mini'
        :loading='loading'
        :height='pageHeight-seachHeight-90'
        :align='left'
        :columns='columns'
        :data='dataSource'
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        :toolbar-config='tableToolbar'
        :checkbox-config="checkboxConfig"
        v-bind='vexConfig'
        @checkbox-change='selectChangeEvent'
        @checkbox-all='selectChangeEvent'
      >
        <template #toolbar_buttons>
          <div class='table-operator'>
<!--            <a-dropdown v-if="selectedRowKeys.length > 0">-->
<!--              <a-menu slot="overlay">-->
<!--                <a-menu-item key="1" @click="batchDel"><a-icon type="delete"/>删除</a-menu-item>-->
<!--              </a-menu>-->
<!--              <a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button>-->
<!--            </a-dropdown>-->
<!--            <a-button type='primary' @click='handleAdd'>新增</a-button>-->
<!--            <a-button type="primary" >导入</a-button>-->
            <a-button type="primary" @click="downExportXls('sfaVisitInfo_service')">导出</a-button>
<!--            <a-button type="primary"  @click="startorstop('009')">日志</a-button>-->

          </div>
        </template>

        <template #status='{ row }'>
          <a-switch :checked='row.status' size='small' @change='handleStatus(row,$event)' />
        </template>
        <template #inUrl='{ row }'>
          <viewer :images='row.inUrl'>
            <a-avatar :src='row.inUrl[0]' icon='user' shape='square' size='small'/>
          </viewer>
        </template>
        <template #outUrl='{ row }'>
          <viewer :images='row.outUrl'>
            <a-avatar :src='row.outUrl[0]' icon='user' shape='square' size='small'/>
          </viewer>
        </template>
        <template #action='{ row:record }'>
          <a @click='handleEdit1(record)'>编辑</a>
          <span v-if='record.fileUrl'>
            <a-divider type='vertical' />
            <a :href='record.fileUrl'>下载</a>
          </span>
        </template>
        <template #pager>
          <vxe-pager
            :layouts="['Total', 'PrevJump', 'PrevPage', 'Number', 'NextPage', 'NextJump','Sizes', 'FullJump']"
            :currentPage.sync='ipagination.current'
            :page-size.sync='ipagination.pageSize'
            :total='ipagination.total'
            :pageSizes='ipagination.pageSizeOptions'
            @page-change='handlePageChange'>
          </vxe-pager>
        </template>
      </vxe-grid>
    </div>
    <!-- table区域-end -->

    <!-- 表单区域 -->
<!--    <sfaVisitInfoEntity-modal ref="modalForm" @ok="modalFormOk"></sfaVisitInfoEntity-modal>-->
  </a-card>
</template>

<script>
  import '@/assets/less/TableExpand.less'
  import JDate from '@comp/cn-form/JDate'
  import {PageListMixin} from '@/mixins/PageListMixin'

  export default {
    name: "SfaVisitInfoList",
    mixins: [PageListMixin],
    components: {
      JDate
    },
    data() {
      return {
        jianShow: '',
        leftjian: require('@/assets/leftjian.png'),
        jiantou: require('@/assets/jiantou.png'),
        message: '',
        imgIndex:0,
        showImg: false,
        imgSrc: [],
        description: '拜访进离店',
        //查询区域
        searchConfig: [
          {
            type: 'input',
            name: 'visitId',
            placeholder: '线路编号'
          },
          {
            type: 'input',
            name: 'infoCode',
            placeholder: '进离店编码'
          },
          {
            type: 'input',
            name: 'createName',
            placeholder: '拜访人姓名'
          },
          {
            type: 'date',
            name: 'createDate',
            placeholder: '拜访日期'
          },
          {
            type: 'j-select',
            name: 'visitType',
            placeholder: '拜访类型',
            dictCode:'visit_type'
          },
        ],
        // 表头
        columns: [
          { type: 'checkbox', width: 50, fixed: 'left' },
          {
            title: '进离店编码',
            minWidth:80,
            field: 'infoCode'
          },
          {
            title: '拜访人',
            minWidth:80,
            field: 'createName'
          },
          {
            title: '拜访日期',
            minWidth:80,
            field: 'createDate'
          },
          {
            title: '拜访类型',
            minWidth:80,
            field: 'visitTypeStr'
          },
          {
            title: '拜访人岗位编号',
            minWidth:140,
            field: 'visitPosCode'
          },
          {
            title: '拜访人岗位名称',
            minWidth:140,
            field: 'visitPosName'
          },
          {
            title: '组织',
            minWidth:80,
            field: 'orgName'
          },
          {
            title: '被协访线路编号',
            minWidth:140,
            field: 'visitAssistId'
          },
          {
            title: '被协访人岗位编号',
            minWidth:140,
            field: 'visitAssistPosCode'
          },
          {
            title: '被协访人岗位名称',
            minWidth:140,
            field: 'visitAssistPosName'
          },
          {
            title: '网点编号',
            minWidth:80,
            field: 'clientCode'
          },
          {
            title: '网点名称',
            minWidth:80,
            field: 'clientName'
          },
          {
            title: '网点类型',
            minWidth:80,
            field: 'clientType'
          },
          {
            title: '进店时间',
            minWidth:80,
            field: 'visitInTime'
          },
          {
            title: '进店状态',
            minWidth:80,
            field: 'visitInStatus'
          },
          {
            title: '进店图片',
            minWidth:80,
            field: 'inUrl',
            slots: { default: 'inUrl' }
          },
          {
            title: '离店时间',
            minWidth:80,
            field: 'visitOutTime'
          },
          {
            title: '离店状态',
            minWidth:80,
            field: 'visitOutStatus'
          },
          {
            title: '离店图片',
            minWidth:80,
            field: 'outUrl',
            slots: { default: 'outUrl' }
          },
          // {
          //   title: '操作',
          //   fixed: 'right',
          //   field: 'action',
          //   minWidth:80,
          //   scopedSlots: {customRender: 'action'},
          // }
        ],
        isorter: {
          permflag: 'visit_leave_list'
        },
        url: {
          list: window._CONFIG['domianSfaURL'] + "/visit/sfaVisitInfoController/findPageList",
          // delete: "/visit/sfaVisitInfoEntity/delete",
          // deleteBatch: "/visit/sfaVisitInfoEntity/deleteBatch",
          exportXlsUrl: window._CONFIG['domianSfaURL'] + "visit/sfaVisitInfoController/exportXls",
          // importExcelUrl: "visit/sfaVisitInfoEntity/importExcel",
        },
      }
    },
    computed: {
      importExcelUrl: function () {
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      }
    },
    methods: {
      clickImg(path) {
        this.imgIndex = 0;
        //console.log(path);
        this.showImg = true;
        // 获取当前图片地址
        this.imgSrc = path;
        //console.log(this.imgSrc)
        this.jianShow = false;
        if (path.length>1){
          this.jianShow = true;
          // console.log(this.jianShow);
        }
      },
      viewImg() {
        this.showImg = false;
      },
      handleClickLeft(){
        if(this.imgIndex===0){
          this.imgIndex=(this.imgSrc.length)-1;
          return
        }
        if(this.imgIndex<this.imgSrc.length && this.imgIndex!==0){
          this.imgIndex--;

        }
      },
      handleClickRight(){
        if(this.imgIndex<(this.imgSrc.length-1)){
          this.imgIndex++;
          return
        }
        if(this.imgIndex===(this.imgSrc.length-1)){
          this.imgIndex=0;

        }

      },
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
  /*动画*/
  .fade-enter-active,
  .fade-leave-active {
    transition: all .2s linear;
    transform: translate3D(0, 0, 0);
  }

  .fade-enter,
  .fade-leave-active {
    transform: translate3D(100%, 0, 0);
  }

  /* bigimg */

  .img-view {
    position: relative;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
  }

  /*遮罩层样式*/
  .img-view .img-layer {
    position: fixed;
    z-index: 99998;
    top: 0;
    left: 0;
    background: rgba(0, 0, 0, 0.7);
    width: 100%;
    height: 100%;
    overflow: hidden;
  }

  /*不限制图片大小，实现居中*/
  .img-view .img img {
    position: absolute;
    min-width: 50%;
    max-width: 50%;
    display: block;
    left: 0;
    right: 0;
    margin: auto;
    z-index: 99999;
  }
  .left {
    position: absolute;
    min-width: 20%;
    max-width: 20%;
    display: block;
    left: 0px;
    margin: auto;
    z-index: 99999;
    top: 50%;
  }
  .right {
    position: absolute;
    min-width: 20%;
    max-width: 20%;
    display: block;
    right: 0px;top: 50%;
    margin: auto;
    z-index: 99999;
  }
</style>